package com.example.boardroom.serial.table.adapter;

import android.view.View;

import androidx.annotation.NonNull;
import androidx.cardview.widget.CardView;

import com.chad.library.adapter.base.entity.node.BaseNode;
import com.chad.library.adapter.base.provider.BaseNodeProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.example.boardroom.R;

public class RootNodeProvider extends BaseNodeProvider {
    @Override
    public int getItemViewType() {
        return 0;
    }

    @Override
    public int getLayoutId() {
        return R.layout.his_item_section;
    }

    @Override
    public void convert(@NonNull BaseViewHolder helper, BaseNode data) {
        // 数据类型需要自己强转
        DAM3200NodeBean entity = (DAM3200NodeBean) data;
        CardView cardView=helper.getView(R.id.cardView);
        if (entity.powerOnState.equalsIgnoreCase("1")) {
            cardView.setCardBackgroundColor(getContext().getResources().getColor(R.color.holo_green_light));
        } else {
            cardView.setCardBackgroundColor(getContext().getResources().getColor(R.color.holo_red_light));
        }

        helper.setText(R.id.tv_electricalParameters,entity.electricalParameters);
        helper.setText(R.id.tv_programParameters,entity.programParameters);

        helper.setText(R.id.tv_name, entity.name);
        helper.setText(R.id.tv_powerOnState, entity.powerOnState.equals("1") ? "通电" : "断电");

    }

    @Override
    public void onClick(@NonNull BaseViewHolder helper, @NonNull View view, BaseNode data, int position) {
        super.onClick(helper, view, data, position);
    }
}
